package com.ksc.storekeeper.client.utils;

public class RegexUtil {

	public static boolean isEmail(String input) {
		if (input.matches("^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(\\.[_A-Za-z0-9-]+)")) {
			return true;
		}
		return false;
	}

	public static boolean isContactNumber(String input) {
		if (isGSMNumber(input) || isGSMPostPaidNumber(input) || isCDMANumber(input) || isCDMAPostPaidNumber(input) || isPhoneNumber(input)) {
			return true;
		}
		return false;
	}

	public static boolean isPhoneNumber(String input) {
		// landline number regex
		if (input.matches("[0-9]{8}")) {
			return true;
		}
		return false;
	}

	public static boolean isMobileNumber(String input) {
		if (isGSMNumber(input) || isCDMANumber(input)) {
			return true;
		}
		return false;
	}

	public static boolean isGSMNumber(String input) {
		if (input.matches("[9][8][0-9]{8}")) {
			return true;
		}
		return false;
	}

	public static boolean isCDMANumber(String input) {
		if (input.matches("[9][7][0-9]{8}")) {
			return true;
		}
		return false;
	}

	public static boolean isCDMAPostPaidNumber(String input) {
		if (input.matches("[9][7][5][0-9]{7}")) {
			return true;
		}
		return false;
	}

	public static boolean isGSMPostPaidNumber(String input) {
		if (input.matches("[9][8][5][0-9]{7}")) {
			return true;
		}
		return false;
	}

	public static boolean isNCellPostpaidNumber(String input) {
		if (input.matches("[9][8][0][1-2][0-9]{6}")) {
			return true;
		}
		return false;
	}

	public static boolean isPostPaidNumber(String input) {
		if (isCDMAPostPaidNumber(input) || isGSMPostPaidNumber(input) || isNCellPostpaidNumber(input)) {
			return true;
		}
		return false;
	}

	public static boolean address(String input) {
		if (input.matches("[a-zA-Z0-9\\s-,]{1,250}")) {
			return true;
		}
		return false;
	}

	public static boolean isAmount(String input) {
		if (isDigit(input) || isDouble(input)) {
			return true;
		}
		return false;
	}

	public static boolean isDigit(String input) {
		if (input.matches("^[\\d]+$")) {
			return true;
		}
		return false;
	}

	public static boolean isDouble(String input) {
		if (input.matches("(\\d+\\.\\d+)?")) {
			return true;
		}
		return false;
	}

	public static boolean isLandline(String input) {
		if (input.length() == 8 && input.matches("^[0-9]+$")) {
			return true;
		}
		return false;
	}

	public static String[] fonepayPaymentPropertiesSplit(String parameters) {
		return parameters.split(",");
	}

	public static boolean isEsewaMobilePIN(String input) {
		if (input.matches("[0-9]{4}")) {
			return true;
		}
		return false;
	}
}
